package com.xiaojie.loabalance;

import org.springframework.cloud.client.ServiceInstance;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@Component
public class RotationLoadBalancer implements  LoadBalancer{
    private AtomicInteger ato=new AtomicInteger(0);
    @Override
    public ServiceInstance getSingleAddress(List<ServiceInstance> list) {
       int index=ato.incrementAndGet()%list.size();
        return list.get(index);
    }
}
